package com.wjh.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.wjh.util.SnowFlakeIdWorker;

/**
 * @author wenjianhai
 * @date 2023/6/21
 * @since JDK 17
 */
@Configuration
public class GlobalBeanConfig {

    @Value("${snow.work.id}")
    private long workId;

    @Value("${snow.data.id}")
    private long dataId;

    /**
     * 引入雪花算法
     * @return 雪花算法
     */
    @Bean
    public SnowFlakeIdWorker getIdWorker() {
        return new SnowFlakeIdWorker(dataId, workId);
    }
}
